(function(window) {
    var Index_subject_detailCtrl = {
        data: {},
        init: function(data) {
            this.bindEven();
            var introNavTop = $(".course_info_top").height();
            //alert(introNavTop);
            $("[data-page='Index_subject_detail']").find(".page-content").scroll(function() {
                var scrollTop = $(this).scrollTop();
                var nav = $("#introNav .nav").find('a');
                if (introNavTop < scrollTop) {
                    $("#introNav").addClass('stuckMenuFix');
                } else {
                    $("#introNav").removeClass('stuckMenuFix');
                }
                $.each(nav, function(i, _this) {
                    var id = $(_this).attr("_href");
                    //	console.log(id);
                    var top = $(id).offset().top;
                    var h = $(id).height();
                    if (-h < top && top < 110) {
                        $(_this).parent().parent().find("li").removeClass('active');
                        $(_this).parent().addClass('active');
                    }
                })
            })


        },
     

       afterShow:function(){
          this.set_top();
       },
        set_top: function() {
            $(".stuckMenu li a").each(function() {
                var id = $(this).attr("_href");
                var h = $(id).offset().top - 120;
                if (!$(this).attr("data-top")) {
                    $(this).attr("data-top", h);
                }

            })
        },

        show_lesson: function() {
            CM.init("BoxEdu", "Subject_lessonCtrl").show_lesson($(this))
        },

        bindEven: function() {
            var bindings = [{
                    // element:document,
                    element: '.learnchapter h3',
                    event: hiApp.device.click,
                    handler: this.show_lesson
                }

            ];
            bindEvents(bindings);
        },
    };

    window.BoxEdu_Index_subject_detailCtrl = Index_subject_detailCtrl;

})(window);
